﻿using Sgr.Security.Permissions;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Sgr.Workspace
{
    /// <summary>
    /// 工作台权限定义
    /// </summary>
    public class Permissions : IPermissionProvider
    {
        /// <summary>
        /// 数据概览权限
        /// </summary>
        public const string QueryDataOverview = "Sgr.Workspace.DataOverview";

        /// <summary>
        /// 我的桌面权限
        /// </summary>
        public const string QueryDesktop = "Sgr.Workspace.MyDesktop";

        /// <summary>
        /// 运营监测
        /// </summary>
        public const string QueryOPS = "Sgr.Workspace.OPS";

        /// <summary>
        /// 权限提供者名称
        /// </summary>
        public string ProviderName => "00-工作台";

        /// <summary>
        /// 获取所有功能权限
        /// </summary>
        public Task<IEnumerable<FunctionPermission>> GetFunctionPermissionsAsync()
        {
            return Task.FromResult(new FunctionPermission[]
            {
                new(QueryDataOverview, "工作台", "数据概览", GrantRoleType.SystemAdmin),
                new(QueryOPS, "工作台", "运营监测", GrantRoleType.SystemAdmin),
                new(QueryDesktop, "工作台", "我的桌面", GrantRoleType.SystemAdmin | GrantRoleType.NormalUser)
            }.AsEnumerable());
        }
    }
}